<?
if($_POST) {
	@include(root_dir . "drizzo-addons/themes/rounded/images/create-images.php");
	@include(root_dir . "drizzo-addons/themes/rounded/create-styles.php");
}
$fonts = array('header_font' => array('label' => 'header_font', 'name' => 'Header'), 'content_headline_font' => array('label' => 'content_headline_font', 'name' => 'Content Headlines'), 'content_font' => array('label' => 'content_font', 'name' => 'Content Text'), 'sidebar_headline_font' => array('label' => 'sidebar_headline_font', 'name' => 'Sidebar Headlines'), 'sidebar_font' => array('label' => 'sidebar_font', 'name' => 'Sidebar Text'), 'footer_font' => array('label' => 'footer_font', 'name' => 'Footer'));
foreach ($fonts as $i => $font) {
	$label = $font['label'];
	if(drizzo_global_options("dryan_rounded_$label")) {
		$fonts[$i]['default'] = drizzo_global_options("dryan_rounded_$label");
	} else {
		$fonts[$i]['default'] = 'sans-serif';
	}
}
$colors = array('bg' => array('label' => 'bg', 'name' => 'Background'), 'header_bg' => array('label' => 'header_bg', 'name' => 'Header Background'), 'header_color' => array('label' => 'header_color', 'name' => 'Header Text'), 'content_headlines' => array('label' => 'content_headlines', 'name' => 'Content Headlines'), 'content_color' => array('label' => 'content_color', 'name' => 'Content Text'), 'content_links' => array('label' => 'content_links', 'name' => 'Content Links'), 'content_meta' => array('label' => 'content_meta', 'name' => 'Content Meta'), 'sidebar_bg' => array('label' => 'sidebar_bg', 'name' => 'Sidebar Background'), 'sidebar_headlines' => array('label' => 'sidebar_headlines', 'name' => 'Sidebar Headlines'), 'sidebar_color' => array('label' => 'sidebar_color', 'name' => 'Sidebar Text'), 'sidebar_links' => array('label' => 'sidebar_links', 'name' => 'Sidebar Links'), 'footer_bg' => array('label' => 'footer_bg', 'name' => 'Footer Background'), 'footer_color' => array('label' => 'footer_color', 'name' => 'Footer Text'), 'footer_links' => array('label' => 'footer_links', 'name' => 'Footer Links'));
foreach ($colors as $i => $color) {
	$label = $color['label'];
	if(drizzo_global_options("dryan_rounded_$label")) {
		$colors[$i]['default'] = preg_replace("[^A-Fa-F0-9]",'',drizzo_global_options("dryan_rounded_$label"));
	} elseif(in_array($label,array('header_bg','sidebar_bg'))) {
		$colors[$i]['default'] = '000000';
	} elseif(in_array($label,array('bg','header_color','sidebar_headlines','footer_text','footer_links'))) {
		$colors[$i]['default'] = 'ffffff';
	} elseif(in_array($label,array('content_color','footer_bg','sidebar_color'))) {
		$colors[$i]['default'] = '808080';
	} elseif(in_array($label,array('content_links','content_headlines','sidebar_links'))) {
		$colors[$i]['default'] = '2866f2';
	} elseif($label == 'content_meta') {
		$colors[$i]['default'] = 'aeaeae';
	}
}
$bgs = array('bg', 'header_bg', 'sidebar_bg', 'footer_bg');
$fgs = array('header_color', 'content_headlines', 'content_color', 'content_links', 'content_meta', 'sidebar_headlines', 'sidebar_color', 'sidebar_links', 'footer_color', 'footer_links');
?>

<script type="text/javascript" charset="utf-8">
	function resetRounded() {
		var inputs=new Array("header_bg","sidebar_bg","bg","header_color","sidebar_headlines","footer_font","footer_links","content_color","footer_bg","sidebar_color","content_meta","content_links","content_headlines","sidebar_links");
		var defaults=new Array("000000","000000","ffffff","ffffff","ffffff","ffffff","ffffff","808080","808080","808080","aeaeae","2866f2","2866f2","2866f2");
		var selects=new Array("header_font","content_headline_font","content_font","sidebar_headline_font","sidebar_font","footer_font","width","style");
		var confirmation = confirm('Are you sure you want to reset all values to default?');
		if(confirmation) {
			for(var i=0;i<inputs.length;i++) {
				$(inputs[i]).value = defaults[i];
				if(inputs[i].indexOf('bg') != -1) {
					updateRoundedBackground(inputs[i]);
				} else {
					updateRoundedColor(inputs[i]);
				}
			}
			for(var i=0;i<selects.length;i++) {
				$(selects[i]).selectedIndex = 0;
			}
		}
	}
	function setRoundedFonts(no) {
		var selects=new Array("header_font","content_headline_font","content_font","sidebar_headline_font","sidebar_font","footer_font","width");
		for(var i=0;i<selects.length;i++) {
			$(selects[i]).selectedIndex = no;
		}
	}
	function nameToHex(id) {
		var names=new Array("AliceBlue","AntiqueWhite","Aqua","Aquamarine","Azure","Beige","Bisque","Black","BlanchedAlmond","Blue","BlueViolet","Brown","BurlyWood","CadetBlue","Chartreuse","Chocolate","Coral","CornflowerBlue","Cornsilk","Crimson","Cyan","DarkBlue","DarkCyan","DarkGoldenRod","DarkGray","DarkGrey","DarkGreen","DarkKhaki","DarkMagenta","DarkOliveGreen","Darkorange","DarkOrchid","DarkRed","DarkSalmon","DarkSeaGreen","DarkSlateBlue","DarkSlateGray","DarkSlateGrey","DarkTurquoise","DarkViolet","DeepPink","DeepSkyBlue","DimGray","DimGrey","DodgerBlue","FireBrick","FloralWhite","ForestGreen","Fuchsia","Gainsboro","GhostWhite","Gold","GoldenRod","Gray","Grey","Green","GreenYellow","HoneyDew","HotPink","IndianRed","Indigo","Ivory","Khaki","Lavender","LavenderBlush","LawnGreen","LemonChiffon","LightBlue","LightCoral","LightCyan","LightGoldenRodYellow","LightGray","LightGrey","LightGreen","LightPink","LightSalmon","LightSeaGreen","LightSkyBlue","LightSlateGray","LightSlateGrey","LightSteelBlue","LightYellow","Lime","LimeGreen","Linen","Magenta","Maroon","MediumAquaMarine","MediumBlue","MediumOrchid","MediumPurple","MediumSeaGreen","MediumSlateBlue","MediumSpringGreen","MediumTurquoise","MediumVioletRed","MidnightBlue","MintCream","MistyRose","Moccasin","NavajoWhite","Navy","OldLace","Olive","OliveDrab","Orange","OrangeRed","Orchid","PaleGoldenRod","PaleGreen","PaleTurquoise","PaleVioletRed","PapayaWhip","PeachPuff","Peru","Pink","Plum","PowderBlue","Purple","Red","RosyBrown","RoyalBlue","SaddleBrown","Salmon","SandyBrown","SeaGreen","SeaShell","Sienna","Silver","SkyBlue","SlateBlue","SlateGray","SlateGrey","Snow","SpringGreen","SteelBlue","Tan","Teal","Thistle","Tomato","Turquoise","Violet","Wheat","White","WhiteSmoke","Yellow","YellowGreen");
		var colors=new Array("F0F8FF","FAEBD7","00FFFF","7FFFD4","F0FFFF","F5F5DC","FFE4C4","000000","FFEBCD","0000FF","8A2BE2","A52A2A","DEB887","5F9EA0","7FFF00","D2691E","FF7F50","6495ED","FFF8DC","DC143C","00FFFF","00008B","008B8B","B8860B","A9A9A9","A9A9A9","006400","BDB76B","8B008B","556B2F","FF8C00","9932CC","8B0000","E9967A","8FBC8F","483D8B","2F4F4F","2F4F4F","00CED1","9400D3","FF1493","00BFFF","696969","696969","1E90FF","B22222","FFFAF0","228B22","FF00FF","DCDCDC","F8F8FF","FFD700","DAA520","808080","808080","008000","ADFF2F","F0FFF0","FF69B4","CD5C5C","4B0082","FFFFF0","F0E68C","E6E6FA","FFF0F5","7CFC00","FFFACD","ADD8E6","F08080","E0FFFF","FAFAD2","D3D3D3","D3D3D3","90EE90","FFB6C1","FFA07A","20B2AA","87CEFA","778899","778899","B0C4DE","FFFFE0","00FF00","32CD32","FAF0E6","FF00FF","800000","66CDAA","0000CD","BA55D3","9370D8","3CB371","7B68EE","00FA9A","48D1CC","C71585","191970","F5FFFA","FFE4E1","FFE4B5","FFDEAD","000080","FDF5E6","808000","6B8E23","FFA500","FF4500","DA70D6","EEE8AA","98FB98","AFEEEE","D87093","FFEFD5","FFDAB9","CD853F","FFC0CB","DDA0DD","B0E0E6","800080","FF0000","BC8F8F","4169E1","8B4513","FA8072","F4A460","2E8B57","FFF5EE","A0522D","C0C0C0","87CEEB","6A5ACD","708090","708090","FFFAFA","00FF7F","4682B4","D2B48C","008080","D8BFD8","FF6347","40E0D0","EE82EE","F5DEB3","FFFFFF","F5F5F5","FFFF00","9ACD32");
		if($(id).value.length > 2) {
			for(var i=0;i<names.length;i++){
				if($(id).value.toLowerCase()==names[i].toLowerCase()){
					$(id).value = colors[i].toLowerCase();
				}
			}
		}
	}
	function updateRoundedBackground(id) {
		nameToHex(id);
		var color = $(id).value;
		var object = 'dryan_rounded_' + id;
		$(object).style.backgroundColor = '#' + color;
	}
	function updateRoundedColor(id) {
		nameToHex(id);
		var color = $(id).value;
		var object = 'dryan_rounded_' + id;
		$(object).style.color = '#' + color;
	}
	function updateRoundedFont(id,font) {
		if(font == 'sans-serif') {
			$(id).style.fontFamily = '"Frutiger","Univers","Helvetica Neue",arial,helvetica,sans-serif';
		} else {
			$(id).style.fontFamily = '"Constantia",Georgia,"Times New Roman",serif';
		}
	}
</script>
<div id="left">
	<p class="right"><a href="javascript:void(0)" onclick="resetRounded()" title="Reset All Values">Reset to Defaults</a></p>
	<label for="dryan_rounded_width">Page Width</label> <select id="width" name="dryan_rounded_width"><option value="fluid"<? if(drizzo_global_options('dryan_rounded_width') == "fluid") { echo " selected"; } ?>>Fluid</option><option value="fixed"<? if(drizzo_global_options('dryan_rounded_width') == "fixed") { echo " selected"; } ?>>Fixed</option></select><br class="clear" />
	<label for="dryan_rounded_style">Rounded or Square</label> <select id="style" name="dryan_rounded_style"><option value="fluid"<? if(drizzo_global_options('dryan_rounded_style') == "rounded") { echo " selected"; } ?>>Rounded</option><option value="square"<? if(drizzo_global_options('dryan_rounded_style') == "square") { echo " selected"; } ?>>Square</option></select><br class="clear" />
	<h3>Fonts <small><a href="javascript:void(0)" onclick="setRoundedFonts(0)">Set all to Sans-Serif</a> | <a href="javascript:void(0)" onclick="setRoundedFonts(1)">Set all to Serif</a></small></h3>
<?
	foreach($fonts as $font) {
		extract($font);
?>
	<label for="dryan_rounded_<? echo $label; ?>"><? echo $name; ?></label> <select id="<? echo $label; ?>" name="dryan_rounded_<? echo $label; ?>" onchange="updateRoundedFont('dryan_rounded_<? echo $label; ?>','this.options[this.selectedIndex].value')"><option value="sans-serif"<? if($default == "sans-serif") { echo " selected"; } ?>>Sans-Serif</option><option value="serif"<? if($default == "serif") { echo " selected"; } ?>>Serif</option></select><br class="clear" />
<?
	}
?>
	<hr class="rule" />
	<h3>Colors</h3>
	<p><strong>Colors can be specified by <a href="http://en.wikipedia.org/wiki/Hex_color" title="Wikipedia article on hex colors">hex color</a> or <a href="http://www.w3schools.com/css/css_colornames.asp" title="W3C article on color names">color name</a></strong></p>
<?
	foreach($colors as $color) {
		extract($color);
?>
	<label for="dryan_rounded_<? echo $label; ?>"><? echo $name; ?> Color</label> <input style="width: 4em" type="text" id="<? echo $label; ?>" name="dryan_rounded_<? echo $label; ?>" value="<? echo $default; ?>" onkeyup="updateRounded<? if(in_array($label,$bgs)) { echo "Background"; } else { echo "Color"; } ?>('<? echo $label; ?>')" /><br class="clear" />
<?
	}
?>
</div>

<div id="right">
	<h3>Preview</h3>
	<p><em>This live preview does not have rounded corners.</em></p>
	<style type="text/css" media="screen">
		#dryan_rounded_bg { 
			font-size: 12px;
			line-height: 1.5em;
			padding: 0 1em;
			margin: 0;
			background: <? echo "#" . $colors['bg']['default']; ?>;
			border: 1px solid #aeaeae;
		}
		#dryan_rounded_bg * {
			padding: 0;
			margin: 0;
			letter-spacing: normal;
			float: none !important;
		}
		#dryan_rounded_header_bg {
			background: <? echo "#" . $colors['header_bg']['default']; ?>;
			color: <? echo "#" . $colors['header_color']['default']; ?>;
			font-size: 1.5em !important;
			line-height: 1em;
			padding: 1.5em 1em;
			margin-bottom: 1em;
			font-family: <? if($fonts['header_font']['default'] == 'sans-serif') { echo '"Frutiger","Univers","Helvetica Neue",arial,helvetica,sans-serif'; } else { echo '"Constantia",Georgia,"Times New Roman",serif'; } ?>;
		}
		#dryan_rounded_content_color {
			width: 65%;
			padding: 0 1em;
			float: left !important;
			color: <? echo "#" . $colors['content_color']['default']; ?>;
			font-family: <? if($fonts['content_font']['default'] == 'sans-serif') { echo '"Frutiger","Univers","Helvetica Neue",arial,helvetica,sans-serif'; } else { echo '"Constantia",Georgia,"Times New Roman",serif'; } ?>;
		}
		#dryan_rounded_content_color h2 {
			font-size: 1.25 !important;
			line-height: 0.8333em !important;
		}
		#dryan_rounded_content_color p {
			margin-bottom: 1.5em;
		}
		#dryan_rounded_content_color blockquote {
			margin: 1em 1.5em;
		}
		#dryan_rounded_sidebar_bg {
			margin-left: 70%;
			padding: 0 1em;
			position: relative;
			background: <? echo "#" . $colors['sidebar_bg']['default']; ?>;
			color: <? echo "#" . $colors['sidebar_color']['default']; ?>;
			font-family: <? if($fonts['sidebar_font']['default'] == 'sans-serif') { echo '"Frutiger","Univers","Helvetica Neue",arial,helvetica,sans-serif'; } else { echo '"Constantia",Georgia,"Times New Roman",serif'; } ?>;
		}
		#dryan_rounded_footer_bg {
			clear: both;
			margin-top: 1em;
			background: <? echo "#" . $colors['footer_bg']['default']; ?>;
			color: <? echo "#" . $colors['footer_color']['default']; ?>;
			font-size: 1em;
			line-height: 1.5em;
			padding: 1.5em 1em;
			text-align: center;
			font-family: <? if($fonts['footer_font']['default'] == 'sans-serif') { echo '"Frutiger","Univers","Helvetica Neue",arial,helvetica,sans-serif'; } else { echo '"Constantia",Georgia,"Times New Roman",serif'; } ?>;
		}
		#dryan_rounded_content_links {
			color: <? echo "#" . $colors['content_links']['default']; ?>;
		}
		#dryan_rounded_sidebar_links {
			color: <? echo "#" . $colors['sidebar_links']['default']; ?>;
		}
		#dryan_rounded_footer_links {
			color: <? echo "#" . $colors['footer_links']['default']; ?>;
		}
		#dryan_rounded_content_meta {
			color: <? echo "#" . $colors['content_meta']['default']; ?>;
		}
	</style>
	<div id="dryan_rounded_bg">
		<div id="dryan_rounded_header_bg">
			<h1 id="dryan_rounded_header_font"><span id="dryan_rounded_header_color"><? echo drizzo_site_name(); ?></span></h1>
		</div>
		<div id="dryan_rounded_content_color">
			<h2 id="dryan_rounded_content_headline_font"><span id="dryan_rounded_content_headlines">Content Headline</span></h2>
			<div id="dryan_rounded_content_font">
				<p>Some content: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam ipsum justo, ultrices sit amet, feugiat aliquam, ornare sit amet, felis. Etiam arcu metus, mollis a, aliquet vel, molestie quis, quam. Suspendisse vel elit id leo aliquam varius. Donec est. Nam gravida. Ut eleifend nisl. Proin sed magna sed elit sollicitudin dapibus. Ut rutrum nisl ut ante. Aenean non augue. <a href="javascript:void(0)" title="faux link" id="dryan_rounded_content_links">Quisque quis lectus.</a> Nam et dui. Vivamus nibh libero, ornare ut, tincidunt vel, mattis ultricies, est. Curabitur gravida fermentum lacus.</p>
				<blockquote>A blockquote: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam ipsum justo, ultrices sit amet, feugiat aliquam, ornare sit amet, felis. Etiam arcu metus, mollis a, aliquet vel, molestie quis, quam.</blockquote>
				<p id="dryan_rounded_content_meta">Meta Info: Tags: rounded, drizzo | Posted: <? echo gmdate(drizzo_global_options('time_format')); ?></p>
			</div>
		</div>
		<div id="dryan_rounded_sidebar_bg">
			<h3 id="dryan_rounded_sidebar_headline_font"><span id="dryan_rounded_sidebar_headlines">Sidebar List</span></h3>
			<div id="dryan_rounded_sidebar_color">
				<ul id="dryan_rounded_sidebar_font">
					<li>List Item 1</li>
					<li><a href="javascript:void(0)" title="faux link" id="dryan_rounded_sidebar_links">List Item 2 (link)</a></li>
				</ul>
			</div>
			<br class="clear" />
		</div>
		<div id="dryan_rounded_footer_bg">
			<p id="dryan_rounded_footer_font"><span id="drizzo_rounded_footer_color"><strong><? echo drizzo_site_name(); ?></strong> is powered by Drizzo <a href="http://drizzoblog.com" title="Drizzo" id="dryan_rounded_footer_links"><? echo drizzo_version_number(); ?></a> &amp; styled by Rounded.</span></p>
		</div>
	</div>
</div>
